import { getAllWareList } from '@/api/warehouse/home';
import store from '@/store';

export const getCurrentAgentPermissionWareHouse = () => {
    return new Promise(resolve => {
        getAllWareList()
            .then(response => {
                const { returnCode, returnData, returnMsg } = response.data;
                if (returnCode === 200) {
                    const currentAgentPermission = !!store.state.user.userInfo.currentAgentPermission;
                    if (currentAgentPermission) {
                        resolve({ data: returnData.filter(i => i.id === 26) });
                    } else {
                        resolve({ data: returnData });
                    }
                } else {
                    resolve({ message: returnMsg });
                }
            })
            .catch(error => {
                resolve({ error });
            });
    });
};
